<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: class.tracking.php 545 2015-02-28 12:01:18Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 545 $
* 	zuletzt geaendert von:	$Author: $
* 	Datum:					$Date: 2015-02-28 12:01:18 +0000 (Sat, 28 Feb 2015) $
*
* 	extends by dirk.mueller (edv-mueller.com)
* 	http://www.itdotmedia.de
*
* --------------------------------------------------------------------------------------
* 	based on:
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
* 	Copyright (c) since 2011 SEO:mercari
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

class tracking {
	var $has_category_changed = false;

	function execute() {
	
	
//		echo_e($_SERVER);
//		echo_e($_POST);
//		echo_e($_GET);

		$call_functions = array(
			'switchCategory',
			
			'customer_bm_switchCategory',
			'customer_bm_switchMpgrKat'
		);
		
		foreach($call_functions as $call_function) {
			if (method_exists($this, $call_function)) {
				call_user_func_array(array($this, $call_function), array());
			}
		}
	
	}
	
	function switchCategory() {
		global $current_category_id;
		//echo_e(array($_SESSION['tracking']['CATEGORY'], $current_category_id));

		if (!isset($_SESSION['tracking']['CATEGORY'])
				|| $_SESSION['tracking']['CATEGORY'] != $current_category_id) {
			//echo_e('switch cat from ' . $_SESSION['tracking']['CATEGORY']	. ' to ' . $current_category_id);
			$this->has_category_changed = true;
		}
		else
			$this->has_category_changed = false;
			
	
	}

	function set($key, $val) {
		$_SESSION['tracking'][$key] = $val;
	}

	function clearCategory() {
		unset($_SESSION['tracking']['CATEGORY']);
	}

	function clear() {
		unset($_SESSION['tracking']['CATEGORY']);
		unset($_SESSION['tracking']['CONTENT']);
		unset($_SESSION['tracking']['MOEBELPROGRAMM']);
	}
	
	function customer_bm_switchCategory() {
		if ($this->has_category_changed) {
			unset($_SESSION['per_site']);
			unset($_SESSION['product_filter']);
			
		}
	}
	
	function customer_bm_switchMpgrKat() {
		global $current_category_id;

		if (isset($_GET['cPath'])) {
			unset($_SESSION['tracking']['CONTENT']);
			unset($_SESSION['tracking']['MOEBELPROGRAMM']);
			$_SESSION['tracking']['CATEGORY'] = $current_category_id;
		}
	
	}

	

}